<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('goods/index')}">商品主页</a></li>
        <li><a href="{:url('goods/add')}">商品添加</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="get" action="{:url('goods/index')}">
        查询:
        <input type="text" class="form-control" name="name" style="width: 240px;" value="{:input('request.user_login/s','')}" placeholder="请输入查询商品名称">
        <input type="submit" class="btn btn-primary" value="搜索" />
        <a class="btn btn-danger" href="{:url('goods/index')}">清空</a>
    </form>
    <form method="post" class="js-ajax-form margin-top-20" action="{:url('goods/order')}">
        <div class="table-actions">
            <button class="btn btn-sm btn-primary js-ajax-submit" type="submit">排序</button>
            <button class="btn btn-sm btn-success js-ajax-submit" type="submit"
                    data-action="{:url('Link/toggle',array('display'=>1))}" data-subcheck="true">显示
            </button>
            <button class="btn btn-sm btn-danger js-ajax-submit" type="submit"
                    data-action="{:url('Link/toggle',array('hide'=>1))}" data-subcheck="true">隐藏
            </button>
        </div>
        <php>$status=array("1"=>lang('DISPLAY'),"0"=>lang('HIDDEN'));</php>
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="16"><label><input type="checkbox" class="js-check-all" data-direction="x"
                                             data-checklist="js-check-x"></label></th>
                <th width="50">排序</th>
                <th width="50">ID</th>
                <th>商品名称</th>
                <th width="50">商品上传图片</th>
                <th width="50">商品款式</th>
                <th width="50">商品图表</th>
                <th width="50">商品内容宣传</th>
                <th width="120">商品出售方式</th>
                <th width="50">经营方式</th>
                <th width="120">商品初始价格</th>
                <th width="120">商品折扣价格</th>
                <th width="120">商品购买数量</th>
                <th width="50">创建时间</th>
                <th width="50">启用状态</th>
                <th width="50">操作</th>
            </tr>
            </thead>
            <tbody>
                <volist name ='data' id = 'v'>
                    <tr>
                        <td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                                   value=""></td>
                        <td><input name='list_orders[{$v.id}]' class="input input-order mr5" type='text' size='3'
                                   value='{$v.list_order}'></td>
                        <td width="50">{$v.id}</td>
                        <td width="50">{$v.name}</td>
                        <td ><img class="image-thumbnail js-image-previewer" onclick="imagePreviewDialog(this.src)" width="20px" src="/upload/{$v.image}"></td>
                        <td >
                            {$v.cate.name|default='查询失败'}
                        </td>
                        <td >
                        <foreach name="$v['chart']" item ='vo'>
                            <img class="image-thumbnail " onclick="imagePreviewDialog(this.src)" width="80px" src="/upload/{$vo}">
                        </foreach>
                        </td>
                        <td width="50">{$v.title}</td>
                        <td>
                            <a href="{:url('goods/changeStatus', ['id' => $v['id']])}" class="btn btn-xs
                            <eq name='$v.status' value='0'> btn-danger</eq>
                            <eq name='$v.status' value='1'> btn-success</eq>
                            <eq name='$v.status' value='2'> btn-warning</eq>
                            js-ajax-dialog-btn"
                               data-msg="确定切换状态吗？">
                                {$statusMap[$v.status]}
                            </a>
                        </td>
                        <td width="50">
                            <a href="{:url('goods/changeStatustwo', ['id' => $v['id']])}" class="btn btn-xs
                            <eq name='$v.switch' value='0'> btn-danger</eq>
                            <eq name='$v.switch' value='1'> btn-success</eq>
                            <eq name='$v.switch' value='2'> btn-warning</eq>
                            js-ajax-dialog-btn"
                               data-msg="确定切换状态吗？">
                                {$Map[$v.switch]}
                            </a>
                        </td>
                        <td width="50">{$v.PrimaryPrice}</td>
                        <td width="50">{$v.DiscountPrice}</td>
                        <td width="50">{$v.number}</td>
                        <td width="50">{$v.create_time}</td>
                        <td width="50">
                            <eq name="$v.switchtwo" value="1">
                                <a href="{:url('goods/totolgSwitchtwo',['id'=>$v['id']])}" type="button" class="btn btn-success js-ajax-dialog-btn" data-msg="确定要进行相反操作吗？" >开启</a>
                                <else/>
                                <a href="{:url('goods/totolgSwitchtwo',['id'=>$v['id']])}" type="button" class="btn btn-danger js-ajax-dialog-btn" data-msg="确定要进行相反操作吗？" >关闭</a>
                            </eq>
                        </td>
                        <td>
                            <div class="btn-group" role="group">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    商品配置<span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu">
                                    <li>
                                        <a href="javascript:void(0)" onclick="openIframeLayer('setGoodsAttr?goods_id={$v.id}','配置商品属性',{area:['60%','80%']})">配置商品属性</a>
                                    </li>
                                    <li>
                                        <a href="javascript:void(0)" onclick="openIframeLayer('setGoodsAttrValue?goods_id={$v.id}','配置商品属性值',{area:['60%','80%']})">配置商品属性</a>
                                    </li>
                                    <li>
                                        <a href="javascript:void(0)" onclick="openIframeLayer('setGoodsAttrdata?goods_id={$v.id}','配置商品属性和属性值',{area:['60%','80%']})">配置商品属性</a>
                                    </li>
                                </ul>
                            </div>

                            <a class="btn btn-xs btn-primary" href="{:url('goods/edit',['id'=>$v['id']])}">编辑</a>
                            <a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('goods/delete',['id'=>$v['id']])}">删除</a>
                        </td>
                    </tr>
                </volist>
            </tbody>
        </table>
        <div class="pagination">

        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js?v={$_static_version}"></script>
<script src="__STATIC__/js/js-image-previewer.js"></script>

<script>
    $(document).ready(function() {
        $('.toggle-switch').click(function() {
            var button = $(this);
            var id = button.data('id');
            $.post("{:url('News/toggleSwitch')}", {id: id}, function(data) {
                if (data.status === 1) {
                    if (data.switch === 1) {
                        button.removeClass('btn-danger').addClass('btn-success').text('是');
                    } else {
                        button.removeClass('btn-success').addClass('btn-danger').text('否');
                    }
                } else {
                    alert(data.msg);
                }
            }, 'json');
        });
    });
</script>
</body>
</html>
